package cn.edu.bit.learn.tool;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;

public class DbManager {
	private static String URI="jdbc:mysql://localhost:3306/Lib";
	private static String PWD="";
	private static String USERNAME="root";
	public static Connection connection=null;

	public Connection getCon(){
		try {
			Class.forName("com.mysql.jdbc.Driver");
			connection =DriverManager.getConnection(URI,USERNAME,PWD);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return connection;
	}
	
	public static void closeResult(ResultSet rs){
		if(rs!=null){
			try {
				rs.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public static void clostStmt(Statement stmt){
		if(stmt!=null){
			try {
				stmt.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public static void closeConn(Connection conn){
		if(conn!=null){
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	public static void main(String args[]){
		DbManager dm = new DbManager();
		
		System.out.println(dm);
	}
				
}		